#include <stdio.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    char *p = "        abcdefg       ";
    int i = 0;
    int n = 0;
    char *start = p;
    char *end = p + strlen(p) - 1;
    //这里采用两头堵的方式一个从左往右，一个从右往左，
    while (*start == ' ' && *start != '\0')
    {
        start++;
    }
    while (*end == ' ' && end != start)
    {
        end--;
    }
    n = end - start + 1;
    printf("total count:%d\n", n);
    //将非空字符全部拷贝出来
    char buf[100] = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";
    strncpy(buf, start, n);
    buf[n] = 0; //为字符串增加结束符;
    printf("not NULL char array: %s\n", buf);
    return 0;
}
